package com.vivachek.protocol.enums

import com.vivachek.protocol.exception.NotSupportProtocolException

/**
 * @Author: YCB
 * @Time: 2022/9/29 15:20
 * @Email: congbin.yuan@vivachek.com
 * @Description: 状态枚举
 *
 */
enum class TestStatusEnums(val code:Int, val desc:String,val type: ResultType) {

    /**
     * 最近一次检测结果
     */
    LAST_TEST_RESULT(16,"最近一次检测结果",ResultType.GLUCOSE),
    /**
     * 已插入试纸
     */
    INSERT_TEST_PAPER(17,"血糖-插入试纸",ResultType.GLUCOSE),

    /**
     * 等待加入样本
     */
    WAIT_ADD_SAMPLE(34,"血糖-等待加入样本",ResultType.GLUCOSE),

    /**
     * 加入样本已完成
     */
    SAMPLE_ADDED(51,"血糖-完成加样",ResultType.GLUCOSE),

    /**
     * 报警码
     */
    WARN_WRAPPER(85,"报警码",ResultType.GLUCOSE),

    /**
     * 血糖结果
     */
    RESULT_GLUCOSE(68,"血糖-结果",ResultType.GLUCOSE),

    /**
     * 血酮 插入试纸
     */
    KETONES_INSERT_STRIP(102, desc = "血酮-插入试纸", type = ResultType.KETONES),

    /**
     * 血酮 完成自检
     */
    KETONES_SELF_CHECK(119, desc = "血酮-完成自检", type = ResultType.KETONES),

    /**
     * 血酮 完成加样
     */
    KETONES_SAMPLE_ADDED(136, desc = "血酮-完成加样", type = ResultType.KETONES),

    /**
     * 血酮结果
     */
    KETONES_RESULT(153, desc = "血酮-结果", type = ResultType.KETONES),

    /**
     * 尿酸插入试纸
     */
    URIC_ACID_INSERT_STRIP(170, desc = "尿酸-插入试纸", type = ResultType.URIC_ACID),

    /**
     * 尿酸-完成自检
     */
    URIC_ACID_SELF_CHECK(187, desc = "尿酸-完成自检", type = ResultType.URIC_ACID),

    /**
     * 尿酸-加样完成
     */
    URIC_ACID_SAMPLE_ADDED(204, desc = "尿酸-加样完成", type = ResultType.URIC_ACID),

    /**
     * 尿酸结果
     */
    URIC_ACID_RESULT(221, desc = "尿酸-结果", type = ResultType.URIC_ACID),

    /**
     * code-chip已插入试纸
     */
    CODE_CHIP_INSERT_STRIP(238, desc = "code-chip已插入试纸", type = ResultType.CODE_CHIP),

    /**
     * code-chip读取结束
     */
    CODE_CHIP_FINISHED(255, desc = "code-chip读取结束", type = ResultType.CODE_CHIP)
    ;
    companion object {
        fun convert(type: Int): TestStatusEnums {
            values().forEach{
                if (it.code == type) {
                    return it
                }
            }
            throw NotSupportProtocolException("无法解析设备反馈的状态")
        }
    }
}